//
//  BDDetailReservationInfoTableViewCell.m
//  BadBoy
//
//  Created by wen on 2017/7/11.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDDetailReservationInfoTableViewCell.h"


@interface BDDetailReservationInfoTableViewCell ()

@property (nonatomic, assign) BOOL haveImageView;
@property (nonatomic, strong) UIView *topLine;
@property (nonatomic, strong) UIView *bottomLine;
@property (nonatomic, strong) UIImageView *rightImageView;

@end

@implementation BDDetailReservationInfoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    style = UITableViewCellStyleValue1;
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
    }
    return self;
}

- (void)configeWithModel:(id)model{
    self.textLabel.text = model[@"title"];
    if (model[@"image"]) {
        self.imageView.image = [UIImage imageNamed:model[@"image"]];
        self.haveImageView = YES;
    }else{
        self.haveImageView = NO;
    }
    if (model[@"subTitle"]) {
        self.detailTextLabel.text = model[@"subTitle"];
    }
    if (model[@"needJiantou"]) {
        self.rightImageView.hidden = NO;
    }
    else{
        self.rightImageView.hidden = YES;
    }
}

- (void)layoutSubviews{
    self.imageView.size = CGSizeMake(20, 20);
    self.imageView.left = 10;
    self.imageView.centerY = self.height / 2.0;
    
    self.textLabel.font = [UIFont systemFontOfSize:15];
    self.textLabel.textColor = [UIColor colorWithHexString:@"#1c1c1c"];
    [self.textLabel sizeToFit];
    self.textLabel.centerY = self.height / 2.0;
    if (self.haveImageView == YES) {
        self.textLabel.left = self.imageView.right + 10;
    }else{
        self.textLabel.left = 10;
    }
    
    self.detailTextLabel.font = [UIFont systemFontOfSize:15];
    self.detailTextLabel.textColor = [UIColor colorWithHexString:@"#1c1c1c"];
    [self.detailTextLabel sizeToFit];
    self.detailTextLabel.centerY = self.height / 2.0;
    self.detailTextLabel.right = self.width - 10;
    
    self.topLine.width = self.width;
    self.topLine.height = 0.5;
    self.topLine.top = 0;
    self.topLine.left = 0;
    
    self.bottomLine.width = self.width;
    self.bottomLine.height = 0.5;
    self.bottomLine.bottom = self.height;
    self.bottomLine.left = 0;
    
    if (self.isFirst == YES) {
        self.topLine.hidden = NO;
    }else {
        self.topLine.hidden = YES;
    }
    
    self.rightImageView.size = CGSizeMake(15, 15);
    self.rightImageView.right = self.width - 10;
    self.rightImageView.centerY = self.height / 2.0;
    self.rightImageView.image = [UIImage imageNamed:@"righ"];
}

- (UIView *)topLine{
    if (!_topLine) {
        self.topLine = [[UIView alloc] init];
        _topLine.backgroundColor = kBDColorGray;
        [self.contentView addSubview:_topLine];
    }
    return _topLine;
}

- (UIView *)bottomLine{
    if (!_bottomLine) {
        self.bottomLine = [[UIView alloc] init];
        _bottomLine.backgroundColor = kBDColorGray;
        [self.contentView addSubview:_bottomLine];
    }
    return _bottomLine;
}

- (UIImageView *)rightImageView{
    if (!_rightImageView) {
        self.rightImageView = [[UIImageView alloc] init];
        [self addSubview:_rightImageView];
    }
    return _rightImageView;
}

@end
